package com.sun.view;

import org.springframework.web.servlet.View;

import java.util.Map;

public class MyView implements View {

    /**
     * Render the view given the specified model.
     * <p>The first step will be preparing the request: In the JSP case, this would mean
     * setting model objects as request attributes. The second step will be the actual
     * rendering of the view, for example including the JSP via a RequestDispatcher.
     *
     * @param model    a Map with name Strings as keys and corresponding model
     *                 objects as values (Map can also be {@code null} in case of empty model)
     * @param request  current HTTP request
     * @param response he HTTP response we are building
     * @throws Exception if rendering failed
     */
    @Override
    public void render(Map<String, ?> model, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws Exception {
        //获取控制器model中存储的数据
        System.out.println(model);
        response.getWriter().write("<h1>展示内容</h1>");
    }

    /**
     * 返回的数据的类型
     */
    @Override
    public String getContentType() {

        return "text/html";
    }
}
